package cn.yunhe.service;

import cn.yunhe.dao.AdminMapper;
import cn.yunhe.entity.Admin;
import cn.yunhe.util.SqlSessionFactoryUtil;
import org.apache.ibatis.session.SqlSession;

public class AdminService {
    SqlSession session = SqlSessionFactoryUtil.getSqlSession();
    AdminMapper adminMapper = session.getMapper(AdminMapper.class);

    public boolean registerAdmin(Admin admin) {
        boolean flag = false;
        try {
            flag = adminMapper.registerAdmin(admin);
            session.commit();
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            session.close();
        }
        return flag;
    }


    public Admin loginAdmin(Admin a) {
        Admin admin = null;
        try {
            admin = adminMapper.loginAdmin(a);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            session.close();
        }
        return admin;
    }


}
